<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserApplyRiskLogsTable extends Migration
{
    const TABLE_NAME = 'user_apply_risk_logs';
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(self::TABLE_NAME, function (Blueprint $table) {
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            $table->increments('id');
            $table->integer('loan_request_id')->comment('授信申请表ID');
            $table->string('risk_id')->comment('风控查询ID');
            $table->string('reason')->default('')->comment('风控审批结果');
            $table->integer('limit')->default(0)->comment('授信额度');
            $table->tinyInteger('status')->default(0)->comment('风控提交状态 0=初始状态 1=通过 2=拒绝 3=继续 4=处理中 5=数据不全 6=风控错误');
            $table->timestamps();
        });
        \DB::statement('ALTER TABLE `'. self::TABLE_NAME.'`CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
        \DB::statement('ALTER TABLE `'. self::TABLE_NAME.'`COMMENT="申请风控返回数据信息表";');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_apply_risk_logs');
    }
}
